import { ChangeEvent, ReactNode } from 'react';
import { CommonProps, IconEnum } from '../common';

export interface SearchOptions extends CommonProps {
  /**
   * 图标
   */
  icon?: boolean | IconEnum;
  /**
   * 分类
   */
  category?: boolean;
  /**
   * 占位字符
   */
  placeholder?: string;
  /**
   * 加载中
   */
  loading?:
    | boolean
    | 'double'
    | 'elastic'
    | 'fast'
    | 'slow'
    | 'double fast'
    | 'double slow'
    | 'elastic fast'
    | 'elastic slow';
  /**
   * 禁用
   */
  disabled?: boolean;
  /**
   * 持续时长
   */
  duration?: number;
  /**
   * 结果
   */
  results?: Array<string | ResultShape>;
  /**
   * 没有结果信息
   */
  noResultsMessage?: ReactNode;
  /**
   * 没有结果描述
   */
  noResultsDescription?: ReactNode;
  /**
   * 输入值改变时触发
   * @param value 输入的值
   * @param event 改变事件
   */
  onChange?: (value?: string, event?: ChangeEvent<HTMLInputElement>) => void;
}

export type ResultShape = {
  category?: string;
  title?: string;
  description?: string;
  image?: string;
  price?: string;
};
